package com.rui.strategy.model;

import com.rui.strategy.obj.pay.Payment;
import lombok.AllArgsConstructor;

/**
 * @Description: 订单交易类
 * @Author: ZhangRui
 * @Date: 2023/3/3 13:47
 * @Version: 1.0
 */
@AllArgsConstructor
public class Order {

    private String uid;

    private double amount;

    public String pay() {
        return pay("cash");
    }

    public String pay(String key) {
        Payment payment = PaymentStrategy.getPayment(key);
        System.out.println("欢迎使用" + payment.getPaymentName());
        System.out.println("本次交易金额:" + this.amount + ",开始扣款...");
        return payment.pay(this.uid, this.amount);
    }

}
